<?php
require("../inc/common.inc.php");
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1 " name="viewport">
<title>幸运大抽奖-<?php echo $webdb["vpp_jigoucode"]?></title>
<meta name="keywords" content="幸运大抽奖,<?php echo $webdb["vpp_jigoucode"]?>" />
<meta name="description" content="幸运大抽奖,<?php echo $webdb["vpp_jigoucode"]?>" />
<link href="../images/style.css" rel="stylesheet" type="text/css" />
<?php $head_hide=1;require("../w_head.php");?>
<style type="text/css">
.demo{width:100%; height:auto; position:relative; padding:10px auto; background:#d88700; overflow:hidden;}
.demo .head{ width:100%; text-align:center; padding-top:10px; padding-bottom:10px;}
.disk{width:95%; height:auto; margin:auto; padding-bottom:10px;}
#prize{margin:10px auto;}
#prize li{float:left; width:50%; height:auto; text-align:center; color:#fff; cursor:pointer;  margin:0px; padding:0px;margin-top:20px; overflow:hidden; list-style-type:none;}
#prize li img{ width:95%;}
#viewother,#repeat{ display:none}


.ggl_div{display:inline-block; position:relative; border:solid #b5b5b5 1px; width:185px; height:30px; background:#b5b5b5; position:absolute; right:20px; bottom:40px;}
.dzp_title1{ color:#FFFFFF; background:#63c2ea; line-height:200%; font-size:1.4em; text-align:center; width:95%; margin:auto; padding:0px;}
.dzp_con{ background:#17a6e0; width:95%; margin:auto; color:#FFFFFF; font-size:1.1em;-moz-border-radius:9px;-webkit-border-radius:9px; padding-bottom:10px;}
.dzp_con h1{ width:95%; color:#fff; font-size:1.4em; line-height:30px; background:url(images/line.png) bottom center no-repeat; padding-bottom:10px; margin:auto;}
.dzp_con h1 img{ float:left; width:30px; margin-right:10px;}
.dzp_con .con2{ width:95%; margin:auto; color:#fff43f;}
</style>
<?php
$sql= "select * from mx_vpp_caipiao where type='2' and isok='1' and startdate<='".date("Y-m-d")."' and enddate>='".date("Y-m-d")."' order by orderid asc,createdate desc,id desc limit 1";
$rsdb= $db -> getinfo($sql);
if ($rsdb['id']<=0) {
	$sql= "select * from mx_vpp_caipiao where type='2' and isok='1' and startdate>='".date("Y-m-d")."' and enddate>='".date("Y-m-d")."' order by startdate asc,createdate desc,id desc limit 1";
	$rsdb= $db -> getinfo($sql);
}
?>
</head>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="jquery-ui-1.7.2.custom.min.js"></script>
<script type="text/javascript" src="jquery.flip.min.js"></script>
<body>
<?php
if ($rsdb["id"]>0){
?>
<div class="demo">
	<div class="head"><img src="images/top.png" style="width:100%;"></div>
	<div class="disk">
     <ul id="prize">
	 	 <?php
		$sql= "select * from mx_vpp_caipiao_prize where isok='1' and cpid = '".$rsdb["id"]."'";
		$prs=$db->excu($sql);
		$i=0;
		if ($db->num_rows($prs)>0){
			while ($prsdb= $db->fetch_array($prs)){
			if ($i%2==0){echo "<div class=\"clear\"></div>";}
		?>
         <li title="点击抽奖"><img src="<?php echo get_photourl($rsdb["picurl"]);?>"></li>
		<?php
			$i++;
			}
		}
		?>
     </ul>
	 <div class="clear"></div>
     <div id="data"></div>
	 <div class="clear"></div>
	</div>
</div>

<div class="clear"></div>
<div class="lingqu" id="viewother" style="margin-top:10px;"><a href="javascript:void(0)">【翻开其他】</a></div>
<div class="clear"></div>
<div class="lingqu" id="repeat" style="margin-top:10px;"><a href="javascript:void(0);">【再来一次】</a></div>
<div class="clear"></div>
<div class="lingqu" style="margin-top:10px;"><a href="/my_cp.php">我的奖品</a></div>
<script type="text/javascript">
$(function(){
	$("#prize li").each(function(){
		var p = $(this);
		var c = $(this).attr('class');
		p.css("background-color",c);
		p.click(function(){
			$("#prize li img").unbind('click');
			$.ajax({
				type:'GET',
				url:'get_choujiang.php?id=<?php echo $rsdb['id'] ?>',
				dataType:'json',
				cache:false,
				success:function(json){
					var prize = json.yes;
					var error = json.error;
					if (error != 0) {
						alert(error);
					} else {
						p.flip({
							direction:'rl',
							content:prize,
							color:c,
							onEnd: function(){
								/*p.css({"font-size":"22px","line-height":"100px"});*/
								p.attr("id","r");
								$("#viewother").show();
								$("#prize li").unbind('click').css("cursor","default").removeAttr("title");
							}
						});
						$("#data").data("nolist",json.no);
					}
				}
			});
		});
	});
	$("#viewother").click(function(){
		var mydata = $("#data").data("nolist"); //获取数据
		var mydata2 = eval(mydata);
			 
		$("#prize li").not($('#r')[0]).each(function(index){
			var pr = $(this);
			pr.flip({
				direction:'bt',
				color:'lightgrey',
				content:mydata2[index],
				onEnd:function(){
					/*pr.css({"font-size":"22px","line-height":"100px","color":"#333"});*/
					$("#viewother").hide();
					$("#repeat").show();
				}
			});
		});
		$("#data").removeData("nolist");
	});
	$("#repeat").click(function(){
		window.location.reload();
	});
});
</script>
   <div class="clear"></div>
   <div class="height10"></div>
   <div class="dzp_con">
   <div class="height10"></div>
   <h1><img src="images/icon1.png">奖项设置</h1>
   <div class="height10"></div>
   <div class="clear"></div>
   <div class="con2">
   <table width="100%" cellpadding="0" cellspacing="0" align="center">
   <?php 
   $rs2=$db->excu("select * from  mx_vpp_caipiao_prize where cpid='$rsdb[id]' and isok='1' and isshowjp='1' order by orderid asc, createdate desc, id desc");
   if ($db->num_rows($rs2)>0){
   	while ($rsdb2=$db->fetch_array($rs2))
	{
   ?>
   <tr><td height="30"><?php echo $rsdb2["name"];?></td><td>奖品数量：<?php echo $rsdb2["num"];?></td></tr>
   <?php
	}
   }
   ?>
   </table>
   </div>
   <div class="height10"></div>
   </div>
   
   <div class="clear"></div>
   <div class="height10"></div>
   <div class="height10"></div>
   <div class="clear"></div>
   
   <div class="dzp_con">
   <div class="height10"></div>
   <h1><img src="images/icon2.png">活动说明</h1>
   <div class="height10"></div>
   <div class="clear"></div>
   <div class="con2">
   <?php echo "每次消耗".$rsdb["needintegral"]."积分<br/>";?>
   <?php echo stripslashes($rsdb["description"]);?>
   </div>
   <div class="height10"></div>
   </div>
   
<?php }else{?>
<div class="demo">
	<div class="head"><img src="images/top.png" style="width:100%;"></div>
</div>
<DIV class="clear"></DIV>
<DIV style="margin-top: 10px;" class="lingqu"><A href="/my_cp.php">我的奖品</A></DIV>

<DIV class="clear"></DIV>
<DIV class="height10"></DIV>

<DIV class="height10"></DIV>
<DIV class="clear"></DIV>
<DIV class="dzp_con">
<DIV class="height10"></DIV>
<H1><IMG src="images/icon1.png">活动说明</H1>
<DIV class="height10"></DIV>
<DIV class="clear"></DIV>
<DIV class="con2">活动已经结束,请继续关注我们!</DIV>
<DIV class="height10"></DIV></DIV>
<?php
}
require("../w_foot.php");
?>